<?php

/**
 * news actions.
 *
 * @package    elearning
 * @subpackage news
 * @author     Your name here
 */
class newsActions extends sfActions
{
  public function executeIndex(sfWebRequest $request)
  {
	$this->pager = NewsPeer::getListByCategoryWithPagination($request->getParameter('cateid',1),15);
	$this->rows = $this->pager->getResults();
	
	$this->cate_item = NewsCategoryPeer::getNewsCategoryDetail($request->getParameter('cateid'));
	//Breadcrumb add items
	prestaBreadcrumb::getInstance()->addItem($this->cate_item->getTitle(), '@news_list?cateid='.$this->cate_item->getId());		
  }

  public function executeShow(sfWebRequest $request)
  {
    $this->rows = NewsPeer::getNewsDetail($request->getParameter('id'));
	if(!empty($this->rows)) {
		//Breadcrumb add items
		$this->cate_item = NewsCategoryPeer::getNewsCategoryDetail($request->getParameter('cateid'));
		$this->related_list = NewsPeer::getListRelated($request->getParameter('id'),$request->getParameter('cateid'));
		
		prestaBreadcrumb::getInstance()->addItem($this->cate_item->getTitle(), '@news_list?cateid='.$this->cate_item->getId());
		prestaBreadcrumb::getInstance()->addItem($this->rows->getTitle(), '@news?cateid='.$this->rows->getNewsCategoryId().'&id='.$this->rows->getId().'&title='.utilities::slugify($this->rows->getTitle()).'.html');
	}
  }
}
